<template>
  <div class="home">
    <div :class="['home_con',wheel]">
      <div>
        <p>personal</p>
        <p>management</p>
        <p>system</p>
        <div @click="$router.push('/login')" class="btn in">
          Sign in
        </div>
        <div @click="$router.push('/register')" class="btn up">
          Sign up
        </div>
        <div @click="change_version" class="btn up" style="height:0px;">
          通用版
        </div>
      </div>
    </div>
    <div :class="['photo',wheel]">
      <div class="photo_list">
        <div class="item">
          <img src="../static/home/1684459754075.jpg" alt="">
        </div>
        <div class="item">
          <img src="../static/home/1684459770811.jpg" alt="">
        </div>
        <div class="item">
          <img src="../static/home/1684459785974.jpg" alt="">
        </div>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  name: 'HomeView',
  data() {
    return {
      wheel: '',
    }
  },

  created() {
    
  },

  mounted() {
    // 监听鼠标滚动事件
    window.addEventListener('mousewheel', this.throttle(this.mousewheel, 300))
  },

  methods: {
    // 滚动鼠标替换css类名
    mousewheel(e) {
      if (e.wheelDelta>0) {
        this.wheel = '';
      }else {
        this.wheel = 'wheel';
      }
    },

    // 节流函数，防止频繁触发鼠标滚动事件
    throttle(fn,wait){
      var pre = Date.now();
      return function(){
        var context = this;
        var args = arguments;
        var now = Date.now();
        if( now - pre >= wait){
          fn.apply(context,args);
          pre = Date.now();
        }
      }
    },
    change_version(){
      location.href=' http://localhost:8084'
    }

  }
}
</script>

<style lang="less" scoped>
.home {
  height: 100%;
  overflow: hidden;
  .wheel {
    transform: translateY(-100%);
  }
  .home_con {
    height: 100%;
    background-size: cover;
    background-image: url(../static/background_image/7719c61a2263fb0c53424b3d8109142.png);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s;
    p {
      text-align: center;
      margin: 0;
      padding: 0;
      font-style: normal;
      font-weight: 400;
      font-size: 96px;
      color: #FFFFFF;
    }
    .btn {
      height: 95px;
      background: rgba(0, 0, 0, 0.62);
      border-radius: 35px;
      line-height: 95px;
      font-style: normal;
      font-weight: 400;
      font-size: 40px;
      text-align: center;
      color: #FFFFFF;
      margin-top: 20px;
      -webkit-user-select:none;
      -moz-user-select:none;
      -ms-user-select:none;
      user-select:none;
      cursor: pointer;
      transition: all 0.2s;
    }
    .btn:hover {
      transform: scale(1.1);
    }
  }
  .photo {
    transition: all 0.4s;
    height: 100%;
    background-size: cover;
    background-image: url(../static/background_image/1684459600197.jpg);
    display: flex;
    align-items: center;
    justify-content: center;
    .photo_list {
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 200px;
      .item {
        font-size: 0;
        margin: 0 30px;
        img {
          width: 305px;
          height: 403px;
        }
      }
    }
  }
}
</style>
